home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
gfx
/
show
/
gs503_data.lha
/
Ghostscript
/
data
/
gs_lev2.ps
< prev
next >
Wrap
Text File
|
1997-08-14
|
15KB
|
460 lines
% Copyright (C) 1990, 1996, 1997 Aladdin Enterprises. All rights reserved.
%
% This file is part of Aladdin Ghostscript.
%
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing. Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
%
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC. The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License. Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.
% Initialization file for Level 2 functions.
% When this is run, systemdict is still writable,
% but (almost) everything defined here goes into level2dict.
level2dict begin
% ------ System and user parameters ------ %
% User parameters are managed entirely in C code.
/currentuserparams { % - currentuserparams <dict>
mark .currentuserparams .dicttomark
} odef
systemdict begin
/getuserparam { % <name> getuserparam <value>
.getuserparam
} odef
end
% Some system parameters are managed entirely at the PostScript level.
% We take care of that here.
systemdict begin
currentdict /systemparams known not {
/systemparams 10 dict readonly def
} if
/getsystemparam { % <name> getsystemparam <value>
//systemparams 1 index .knownget { exch pop } { .getsystemparam } ifelse
} odef
end
/currentsystemparams { % - currentsystemparams <dict>
mark .currentsystemparams //systemparams { } forall .dicttomark
} odef
/.setsystemparams /setsystemparams load def
/setsystemparams { % <dict> setsystemparams -
% Check that we will be able to set the PostScript-level
% system parameters.
dup
{ //systemparams 3 -1 roll .knownget
{ type 1 index type ne
{ pop /setsystemparams load /typecheck signalerror }
if
dup type /stringtype eq
{ dup dup gcheck exch rcheck or not
{ /setsystemparams load /invalidaccess signalerror }
if
}
if pop
}
{ pop
}
ifelse
}
forall
% Set the C-level system params. If this succeeds, we know that
% the password check succeeded.
dup .setsystemparams
% Now set the PostScript-level params. We must copy local strings
% into global VM.
dup
{ //systemparams 2 index known
{ % Stack: key newvalue
dup gcheck not
{ % The only composite objects that can have passed
% the type check are strings.
.currentglobal true .setglobal
1 index length string exch .setglobal
copy readonly
}
if //systemparams 3 1 roll .forceput
}
{ pop pop
}
ifelse
}
forall pop
} odef
% ------ Miscellaneous ------ %
(<<) cvn % - << -mark-
/mark load def
(>>) cvn % -mark- <key1> <value1> ... >> <dict>
/.dicttomark load def
/languagelevel 2 def
% When running in Level 2 mode, this interpreter is supposed to be
% compatible with PostScript version 2010 (I think).
/version (2010) def
% If binary tokens are supported by this interpreter,
% set an appropriate default binary object format.
/setobjectformat where
{ pop
/RealFormat getsystemparam (IEEE) eq { 1 } { 3 } ifelse
/ByteOrder getsystemparam { 1 add } if
setobjectformat
} if
% ------ Virtual memory ------ %
/currentglobal % - currentglobal <bool>
/currentshared load def
/gcheck % <obj> gcheck <bool>
/scheck load def
/setglobal % <bool> setglobal -
/setshared load def
% We can make the global dictionaries very small, because they auto-expand.
/globaldict currentdict /shareddict .knownget not { 4 dict } if def
/GlobalFontDirectory SharedFontDirectory def
% ------ IODevices ------ %
/.getdevparams where {
pop /currentdevparams { % <iodevice> currentdevparams <dict>
.getdevparams .dicttomark
} odef
} if
/.putdevparams where {
pop /setdevparams { % <iodevice> <dict> setdevparams -
mark 1 index { } forall counttomark 2 add index
.putdevparams pop pop
} odef
} if
% ------ Job control ------ %
serverdict begin
% We could protect the job information better, but we aren't attempting
% (currently) to protect ourselves against maliciousness.
/.jobsave null def % top-level save object
/.jobsavelevel 0 def % save depth of job (0 if .jobsave is null,
% 1 otherwise)
/.adminjob true def % status of current unencapsulated job
/exitserver { % <password> exitserver -
true exch startjob not { /exitserver /invalidaccess signalerror } if
} bind def
end % serverdict
% Because there may be objects on the e-stack created since the job save,
% we have to clear the e-stack before doing the end-of-job restore.
% We do this by executing a 2 .stop, which is caught by the 2 .stopped
% in .runexec; we leave on the o-stack a procedure to execute aftewards.
%
%**************** The definition of startjob is not complete yet, since
% it doesn't reset stdin/stdout or other aspects of the interpreter.
/.finishstartjob { % <exit_bool> <password_level>
% .finishstartjob -true-
serverdict /.jobsave get dup null eq { pop } { restore } ifelse
exch {
% Unencapsulated job
serverdict /.jobsave null put
serverdict /.jobsavelevel 0 put
serverdict /.adminjob 3 -1 roll 1 gt put
} {
% Encapsulated job
pop
serverdict /.jobsave save put
serverdict /.jobsavelevel 1 put
userdict /quit /stop load put
} ifelse true
} bind def
/startjob { % <exit_bool> <password> startjob <ok_bool>
vmstatus pop pop serverdict /.jobsavelevel get eq
1 index .checkpassword 0 gt and {
.checkpassword count 2 roll count 2 sub { pop } repeat
cleardictstack
% Reset the e-stack back to the 2 .stopped in .runexec.
{ .finishstartjob } 2 .stop
} { % Password check failed
pop pop false
} ifelse
} odef
systemdict begin
/quit { % - quit -
//systemdict begin serverdict /.jobsave get null eq
{ end //quit }
{ /quit load /invalidaccess /signalerror load end exec }
ifelse
} bind odef
end
% ------ Compatibility ------ %
% In Level 2 mode, the following replace the definitions that gs_statd.ps
% installs in statusdict and serverdict.
% Note that statusdict must be allocated in local VM.
% We don't bother with many of these yet.
/.dict1 { exch mark 3 1 roll .dicttomark } bind def
currentglobal false setglobal 25 dict exch setglobal begin
currentsystemparams
/buildtime 1 index /BuildTime get def
/byteorder 1 index /ByteOrder get def
/checkpassword { .checkpassword 0 gt } bind def
/defaulttimeouts
{ currentsystemparams dup
/JobTimeout .knownget not { 0 } if
exch /WaitTimeout .knownget not { 0 } if
currentpagedevice /ManualFeedTimeout .knownget not { 0 } if
} bind def
dup /DoStartPage known
{ /dostartpage { /DoStartPage getsystemparam } bind def
/setdostartpage { /DoStartPage .dict1 setsystemparams } bind def
} if
dup /StartupMode known
{ /dosysstart { /StartupMode getsystemparam 0 ne } bind def
/setdosysstart { { 1 } { 0 } ifelse /StartupMode .dict1 setsystemparams } bind def
} if
%****** Setting jobname is supposed to set userparams.JobName, too.
/jobname { /JobName getuserparam } bind def
/jobtimeout { /JobTimeout getuserparam } bind def
%manualfeed
%manualfeedtimeout
/margins
{ currentpagedevice /Margins .knownget { exch } { [0 0] } ifelse
} bind def
%pagecount
%pagestackorder
/printername
{ currentsystemparams /PrinterName .knownget not { () } if exch copy
} bind def
%/ramsize { /RamSize getsystemparam } bind def
/realformat 1 index /RealFormat get def
/.setpagedevice where
{ pop
/setdefaulttimeouts
{ exch mark /ManualFeedTimeout 3 -1 roll
/Policies mark /ManualFeedTimeout 1 .dicttomark
.dicttomark setpagedevice
/WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams
} bind def
/setmargins
{ exch 2 array astore /Margins .dict1 setpagedevice
} bind def
}
if
%setpagestackorder
dup /PrinterName known
{ /setprintername { /PrinterName .dict1 setsystemparams } bind def
} if
currentuserparams /WaitTimeout known
{ /waittimeout { /WaitTimeout getuserparam } bind def
} if
/.setpagedevice where
{ pop
/pagemargin
{ currentpagedevice /PageOffset .knownget { 0 get } { 0 } ifelse
} bind def
/pageparams
{ currentpagedevice
dup /Orientation .knownget { 1 and ORIENT1 { 1 xor } if } { 0 } ifelse exch
dup /PageSize get aload pop 3 index 0 ne { exch } if 3 2 roll
/PageOffset .knownget { 0 get } { 0 } ifelse 4 -1 roll
} bind def
/.setpagesize { 2 array astore /PageSize .dict1 setpagedevice } bind def
/setduplexmode { /Duplex .dict1 setpagedevice } bind def
/setpagemargin { 0 2 array astore /PageOffset .dict1 setpagedevice } bind def
/setpageparams
{ mark /PageSize 6 -2 roll
4 index 1 and ORIENT1 { 1 } { 0 } ifelse ne { exch } if 2 array astore
/Orientation 5 -1 roll ORIENT1 { 1 xor } if
/PageOffset counttomark 2 add -1 roll 0 2 array astore
.dicttomark setpagedevice
} bind def
/setresolution
{ dup 2 array astore /HWResolution .dict1 setpagedevice
} bind def
}
if
pop % currentsystemparams
% Flag the current dictionary so it will be swapped when we
% change language levels. (See zmisc2.c for more information.)
/statusdict currentdict def
currentdict end
/statusdict exch def
% ------ Color spaces ------ %
% Define the setcolorspace procedures:
% <colorspace> proc <colorspace'|null>
/colorspacedict mark
/DeviceGray { pop 0 setgray null } bind
/DeviceRGB { pop 0 0 0 setrgbcolor null } bind
/setcmykcolor where
{ pop /DeviceCMYK { pop 0 0 0 1 setcmykcolor null } bind
} if
/.setcieaspace where
{ pop /CIEBasedA { NOCIE { pop 0 setgray null } { dup 1 get .setcieaspace } ifelse } bind
} if
/.setcieabcspace where
{ pop /CIEBasedABC { NOCIE { pop 0 0 0 setrgbcolor null } { dup 1 get .setcieabcspace } ifelse } bind
} if
/.setciedefspace where
{ pop /CIEBasedDEF { NOCIE { pop 0 0 0 setrgbcolor null } { dup 1 get .setciedefspace } ifelse } bind
} if
/.setciedefgspace where
{ pop /CIEBasedDEFG { NOCIE { pop 0 0 0 1 setcmykcolor null } { dup 1 get .setciedefgspace } ifelse } bind
} if
/.setseparationspace where
{ pop /Separation { dup 2 get setcolorspace dup .setseparationspace } bind
} if
/.setindexedspace where
{ pop /Indexed { dup 1 get setcolorspace dup .setindexedspace } bind
} if
/.nullpatternspace [/Pattern] readonly def
/.setpatternspace where
{ pop /Pattern
{ dup type /nametype eq { pop //.nullpatternspace } if
dup length 1 gt { dup 1 get setcolorspace } if
dup .setpatternspace
} bind
} if
currentdict /.nullpatternspace .undef
.dicttomark def
/.devcs [/DeviceGray /DeviceRGB /DeviceCMYK] readonly def
/currentcolorspace { % - currentcolorspace <array>
.currentcolorspace dup type /integertype eq {
//.devcs exch 1 getinterval
} if
} odef
currentdict /.devcs .undef
/setcolorspace { % <name|array> setcolorspace -
dup dup dup type /nametype ne { 0 get } if
//colorspacedict exch get exec
dup null eq { pop } { .setcolorspace } ifelse pop
} odef
% ------ CIE color rendering ------ %
/setcolorrendering where { pop } { (%END CRD) .skipeof } ifelse
% Initialize the CIE rendering dictionary if necessary.
% The most common CIE files seem to assume the "calibrated RGB color space"
% described on p. 189 of the PostScript Language Reference Manual,
% 2nd Edition; we simply invert this transformation back to RGB.
mark
/ColorRenderingType 1
% We must make RangePQR and RangeLMN large enough so that values computed by
% the assumed encoding MatrixLMN don't get clamped.
/RangePQR [0 0.9505 0 1 0 1.0890]
/TransformPQR [ { 4 { exch pop } repeat } dup dup ]
/RangeLMN [0 0.9505 0 1 0 1.0890]
/MatrixABC
[ 3.24063 -0.96893 0.05571
-1.53721 1.87576 -0.20402
-0.49863 0.04152 1.05700
]
/EncodeABC [{0 max 0.45 exp} bind dup dup]
/WhitePoint [0.9505 1 1.0890]
% Some Genoa tests seem to require the presence of BlackPoint.
/BlackPoint [0 0 0]
.dicttomark setcolorrendering
% Define findcolorrendering and a default ColorRendering ProcSet.
/findcolorrendering { % <intentname> findcolorrendering
% <crdname> <found>
/ColorRendering /ProcSet findresource
1 index .namestring (.) concatstrings
1 index /GetPageDeviceName get exec .namestring (.) concatstrings
2 index /GetHalftoneName get exec .namestring
concatstrings concatstrings
dup /ColorRendering resourcestatus {
pop pop exch pop exch pop true
} {
pop /GetSubstituteCRD get exec false
} ifelse
} odef
5 dict dup begin
/GetPageDeviceName { % - GetPageDeviceName <name>
currentpagedevice dup /PageDeviceName .knownget {
exch pop
} {
pop /none
} ifelse
} bind def
/GetHalftoneName { % - GetHalftoneName <name>
currenthalftone /HalftoneName .knownget not { /none } if
} bind def
/GetSubstituteCRD { % <intentname> GetSubstituteCRD <crdname>
pop /DefaultColorRendering
} bind def
end
% The resource machinery hasn't been activated, so just save the ProcSet
% and let .fixresources finish the installation process.
/ColorRendering exch def
%END CRD
% ------ Painting ------ %
% A straightforward definition of execform that doesn't actually
% do any caching.
/.execform1
{ % This is a separate operator so that the stacks will be restored
% properly if an error occurs.
dup /Implementation known not
{ dup /FormType get 1 ne { /rangecheck signalerror } if
dup /Implementation null put readonly
} if
dup /Matrix get concat
dup /BBox get aload pop
exch 3 index sub exch 2 index sub rectclip
dup /PaintProc get exec
} odef
/execform % <form> execform -
{ gsave { .execform1 } stopped grestore { stop } if
} odef
/makepattern { % <proto_dict> <matrix> makepattern <pattern>
1 index dup length 1 add currentglobal
{ false setglobal dict .copydict 1 index .buildpattern true setglobal }
{ dict .copydict 1 index .buildpattern }
ifelse
1 index /Implementation 3 -1 roll put
readonly exch pop exch pop
} odef
/setpattern { % [<comp1> ...] <pattern> setpattern -
currentcolorspace 0 get /Pattern ne {
[ /Pattern currentcolorspace ] setcolorspace
} if setcolor
} odef
end % level2dict